//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "tools\fn_displayName.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_object","_obj_name","_obj_kind","_cfg","_display"];
DEFAULT_PARAM(_object,0,objNull);
DEFAULT_PARAM(_obj_kind,1,-1);
_obj_name = _object;
if (IS_OBJECT(_object)) then {
	_obj_name = typeof _object;
};
if (!IS_STRING(_obj_name)) then {
	_obj_name = str(_obj_name);
};
_cfg = "";
if (IS_SCALAR(_obj_kind)) then {
	_cfg = switch (_obj_kind) do {
		case 0: {"CfgVehicles"};
		case 1: {"CfgWeapons"};
		case 2: {"CfgMagazines"};
		default { "" };
	};
};
if (_cfg == "") then {
	TRACE_1("Object Kind",ARR_5(_obj_name,_obj_kind,isclass(configFile >> "CfgVehicles" >> _obj_name),isclass(configFile >> "CfgWeapons" >> _obj_name),isclass(configFile >> "CfgMagazines" >> _obj_name)));
	_cfg = switch (true) do {
		case (isclass(configFile >> "CfgMagazines" >> _obj_name)): { "CfgMagazines" };
		case (isclass(configFile >> "CfgWeapons" >> _obj_name)): { "CfgWeapons" };
		case (isclass(configFile >> "CfgVehicles" >> _obj_name)): { "CfgVehicles" };
		default { "CfgVehicles" };
	};
};
TRACE_1("Searching Name",ARR_3(_obj_kind,_cfg,_obj_name));
_display = getText (configFile >> _cfg >> _obj_name >> "displayName");
if (isnil "_display") then { _display = _obj_name; };
if (_display == "") then { _display = _obj_name; };
TRACE_1("End",_display);
TMFPROFILERSTOP;
_display;